
<template>
	<view class="content">
		
		<view class="login_img"><image mode="aspectFill" src="https://img1.baidu.com/it/u=3828044059,2336306651&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500"></image></view>
		
		<view class="login_from">
			
			
			<view class="login_from_input">
				<view class="login_from_name">账号</view>
				<view class="login_from_fun"><input  v-model="loginDate.username" type="text" placeholder="请输入账号或者手机号码"></view>
			</view>
			<!-- <view class="">
						<view class="login_from_fun"><input type="text" placeholder=""></view>
					</view> -->
			<!-- <view class="">
				<view class="login_from_fun"><input type="text" placeholder="未注册手机号将自动创建"></view>
			</view> -->
			<!-- 
			<view class="">
						<view class="login_from_fun"><input type="text" placeholder=""></view>
					</view> -->
			
			<view class="login_from_input">
				<view class="login_from_name">密码</view>
				<view  class="login_from_fun"><input v-model="loginDate.password" type="digit" password="true" placeholder="请输入登录密码"></view>
			</view>
			<view class="AddUser" @click="AddUser(url)" style="color: darkgrey;margin-top: 5%;" >
				<text @click="zhuce" >无账号,点击此注册</text>
			</view>
			
	
				<view class="login_from_dl">
							<button @click="denglu">登录</button>
				</view>
			
			<view class="logo_xieyi">
				<label @click="moutcl" :class="gouxSta?'cuIcon-squarecheckfill':'cuIcon-square'"></label>
				<view class="logo_text">请勾选并阅读<text>《注册协议》</text>及<text>《隐私协议》</text></view>
			</view>
			
		</view>
		
	</view>
</template>
<script>
 export default {
   data(){
     return {
		gouxSta:false,
		loginDate:{
			
		}
		 
	}
	   },
    onLoad(){
     },
    methods: {
		
		moutcl(){
			
			if( this.gouxSta == false){
				
				this.gouxSta = true
				
			}else{
				
				this.gouxSta = false
				
			}
			
		},
	
			
		AddUser(url){
			
			
			uni.navigateTo({
				url:"../AddUser/AddUser"
			})
		}
		,
		
		
		denglu(){
			
			console.log(this.loginDate)
			
			let msg='';
			
			
			if( this.gouxSta == false){
				
				uni.showToast({
					"title":"请阅读并勾选用户协议",
					"icon":'none'
				})		
						
				
			}
			// uni.request({
			// 	url:'http://xuyifeitest.natapp1.cc/signUser',
			// 	method:"POST",
			// 	data:this.loginDate,
			// 	success:(res)=>{
			// 		console.log(res)
			// 		const data=res.data
						
			// 		if(data.code=='300'){
			// 			uni.showToast({
			// 				icon:"none",
			// 				title:'登录失败',
							
			// 			})
						
			// 		}else{
						
							
					
			// 			uni.showToast({
							
			// 				  title: "登录成功，欢迎进入 " + data.data.username,
			// 				})
							
							
			// 			setTimeout(function() {
			// 			  uni.switchTab({
			// 			    url: '/pages/index/index'
			// 			  })
			// 			}, 600);
			// 			//存储用户的数据到storage
			// 			uni.setStorageSync('user',data.data)
						
			// 			// uni.switchTab({
			// 			// 	url:'/pages/index/index'
			// 			// })
						
			// 		}
				
				
			// 	}
			// })
			
			
			uni.request({
			  url: 'http://xuyifeitest.natapp1.cc/signUser',
			  method: "POST",
			  data: this.loginDate,
			  success: (res) => {
			    console.log(res)
				console.log(res.data)
			    const data = res.data
			
			    if (data.code == '300') {
			      uni.showToast({
			        icon: "none",
			        title: '登录失败',
			      })
			
			    } else {
				  //存储用户的数据到storage
				  uni.setStorageSync('username', data.data[0].username)
			      uni.showToast({
			        title: "登录成功，欢迎进入 "+ data.data[0].username, 
					// title:data.data[0].username+"用户,欢迎进入 !",+ data.data[0].username,
			        success: () => {
			          setTimeout(function () {
			            uni.switchTab({
			              url: '/pages/index/index'
			            })
			          }, 500);
			        }
			      })
			     
			    }
			  }
			})

			
			
			
			
			
			
			
				
			}
		}

 }
</script>
<style>
	
	page{ background: #fff;font-family: arial,verdana,helvetica,'PingFang SC','HanHei SC',STHeitiSC-Light,Microsoft Yahei,sans-serif; }
	
	.login_img{ width: 100%; height: auto; margin-top: 90upx; }
	.login_img image{ width: 200upx; height: 200upx; display: block; margin: 0px auto; border-radius: 50%; }
	
	.login_from{ width: 100%; height: auto; box-sizing: border-box; padding: 40upx 8%; margin-top: 80upx; }
	
	.login_from_input{ width: 100%; height:auto; display: flex; flex-direction: row; justify-content: space-between; align-items: center; border-bottom: 1px #eee solid  ; padding: 50upx 0px; margin: 0px auto;  } 
	
	.login_from_name{ width: 20%; }
	.login_from_fun{ width: 80%; display: flex; flex-direction: row; justify-content: flex-end;  }
	.login_from_fun input{ width: 100%; text-align: left; font-size: 14px;  }
	
	
	.login_from_dl{ width: 100%; height: 50px; line-height: 50px; margin-top: 150upx;   }
	.login_from_dl button{ width: 100%; height: 50px; line-height: 50px; background: #007AFF; color: #fff; border-radius: 0px; }
	
	.logo_xieyi{ width: 100%; height: 40px; line-height: 40px; display: flex; flex-direction: row; margin-top: 30upx; align-items: center; color: #444; font-size: 14px; justify-content: center; }
	.logo_xieyi label{ font-size: 18px; margin-right: 1%; display: block; width: 15px; height: 15px; }
	
	.cuIcon-squarecheckfill{ color: #007AFF; }
	.logo_text text{ color: #007AFF; }
	.cuIcon-squarecheckfill{ background: #007AFF; position: relative; border: 2px #ccc solid; box-sizing: border-box; border-radius: 3px; }
	.cuIcon-square{ background: #fff; border: 2px #ccc solid; box-sizing: border-box; border-radius: 3px; }
	
</style>



